package com.hh.servlet.edata;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hh.dao.ZhiLiaoDao;

import java.io.IOException;
@WebServlet("/zhiliao")
public class ZhiLiao extends HttpServlet {

    private static final long serialVersionUID = 1L;

    public ZhiLiao() {
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	doPost(request,response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setHeader("content-type", "text/html;charset=UTF-8");
        /* 允许跨域的主机地址 */
        response.setHeader("Access-Control-Allow-Origin", "*");  
        /* 允许跨域的请求方法GET, POST, HEAD 等 */
        response.setHeader("Access-Control-Allow-Methods", "*");  
        /* 重新预检验跨域的缓存时间 (s) */
        response.setHeader("Access-Control-Max-Age", "3600");  
        /* 允许跨域的请求头 */
        response.setHeader("Access-Control-Allow-Headers", "*");  
        /* 是否携带cookie */
        response.setHeader("Access-Control-Allow-Credentials", "true");
        String key = request.getParameter("key");
        String pageSize = request.getParameter("pageSize");
        String mzhm = request.getParameter("mzhm");
        ZhiLiaoDao zhiLiaoDao = new ZhiLiaoDao();
        response.getWriter().print(zhiLiaoDao.getZhiLiaoList(key,pageSize,mzhm));
    }

}
